//
// Created by liu on 2019/10/5.
//

#ifndef DESIGNPATTERNS_SIMPLEFACTORY_H
#define DESIGNPATTERNS_SIMPLEFACTORY_H

# include <iostream>
# include <string>

// 简单工厂模式

class Book{
public:
    virtual void Name() = 0;
};

class System : public Book{
public:
    void Name()
    {
        std::cout<<"System"<<std::endl;
    }
};

class NetWork : public Book{
public:
    void Name()
    {
        std::cout<<"NetWork"<<std::endl;
    }
};

class BookFactory{
public:
    Book* factoryMethod(std::string arg)
    {
        if (arg == "System")
            return new System();
        else if (arg == "NetWork")
            return new NetWork();
        else
            return nullptr;
    }
};

#endif //DESIGNPATTERNS_SIMPLEFACTORY_H
